package com.laysonx.data.police.support;

import com.laysonx.data.police.annotation.EnableDataVerify;
import com.laysonx.data.police.exception.DataVerifyFailException;
import com.laysonx.data.police.handler.AbstractDisposeHandler;
import org.aopalliance.intercept.MethodInvocation;

/**
 * 默认验证后处理方式
 * @author: Laysonx
 * @date: 2019/10/22 15:33
 */
public class DefaultBeanDisposeHandler extends AbstractDisposeHandler {

    @Override
    public Class<?> getTargetClass() {
        return DefaultBean.class;
    }

    @Override
    public void dispose(Boolean verifySuccess, MethodInvocation invocation, EnableDataVerify enableDataVerify) {
        if(!verifySuccess){
            throw new DataVerifyFailException(enableDataVerify.errorMessage());
        }
    }
}
